package com.bjsxt.service.impl;

import com.bjsxt.service.feign.AccountServiceFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class AccountServiceApi {

//    @Autowired
//    private RestTemplate restTemplate ;

    @Autowired
    private AccountServiceFeign accountServiceFeign ;

    public ResponseEntity<Void> debit(String userId,int money){

        /**
         * 发起对account-service的远程调用
         */
//        ResponseEntity<Void> responseEntity = restTemplate.getForEntity(
//                "http://account-service/debit/{userId}/{money}",
//                Void.class,
//                userId,
//                money
//
//        );
        ResponseEntity<Void> responseEntity = accountServiceFeign.debit(userId, money);

        return responseEntity ;
    }
}
